#! /usr/bin/env python2.4
"""
cgi test script for SimpleJSONRPCServer
"""
from SimpleJSONRPCServer import CGIJSONRPCRequestHandler
import subprocess

class MyFuncs:
    def div(self, x, y) : return div(x,y)
    def subtract(self, x, y) : return x - y
    def get_names_of_running_workflows(self):
	    proc = subprocess.Popen('python ace_stub.py', shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
	    proc.stdin.write('13\n')    # none of the messages will be sent w/o '\n'	    output = proc.stdout.readline()	    #print output.rstrip() # rstrip removes the \n
	    return ['A', 'B', 'C']

handler = CGIJSONRPCRequestHandler()
handler.register_function(pow)
handler.register_function(lambda x,y: x+y, 'add')
handler.register_introspection_functions()
handler.register_instance(MyFuncs())
handler.handle_request()


